/*
 *  Copyright 2008 Mark Ashworth <javameme@gmail.com>.
 * 
 *  Licensed under the GNU General Public License v3 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.gnu.org/licenses/gpl-3.0.html
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package metaphor.persistence;

/**
 * An interface for specifying how to determine if an object is unsaved. This
 * strategy is called in the Dao.save() method to determine if an object should
 * be inserted or updated.
 * 
 * @author Mark Ashworth <javameme@gmail.com>
 * @version 1.0.0
 */
public interface UnsavedValueStrategy {
    /**
     * Returns whether the object should be considered a new object and the
     * persistent mechanism should try to insert the object. If false is 
     * returned then the persistence mechanism can try to update the
     * object in the persistent store.
     * 
     * @param object The object that should be tested
     * @return true if object is new else false
     */
    boolean isNew(Object object) throws UnsavedValueStrategyException;
}
